<?php
// +--------------------------------------------------------------------------------------------
// | Author: Admin <543423@qq.com>
// +--------------------------------------------------------------------------------------------
// | Copyright ThinkAdmin http://www.thinkadmin.cn All rights reserved.
// +--------------------------------------------------------------------------------------------

/**
 * +--------------------------------------------------------------------------------------------
 * |视图输出过滤行为
 * +--------------------------------------------------------------------------------------------
 * |视图输出过滤行为是对视图输出过滤，如过滤模板的换行，多余回车等等，可以自行添加需要的过滤
 * +--------------------------------------------------------------------------------------------
 */

namespace Common\Behavior;
class ViewFilterBehavior{
	
	/**
	 * 
	 *  行为扩展的执行入口
	 * @param  $content 接收参数
	 */
	public function run(&$content){
		if(C('TMPL_STRIP_SPACE')){
			$content = str_replace("\r\n", "", $content);//过滤换行
			$content = preg_replace("/\s+/", " ", $content);//过滤多余回车
			$content = preg_replace("/<\!--.*?-->/si", "", $content); //过滤HTML注释
		}
	}
}